set wordLength to the number of chars in scrambleWord
set scrambledNombre to EMPTY
repeat with i = 1 to wordLength
put char i of scrambleWord before scrambledNombre
put numToChar(random(70) + 48) before scrambledNombre
put numToChar(random(70) + 48) before scrambledNombre
end repeat
return scrambledNombre
end
on unscramble scrambledWord
set wordLength to the number of chars in scrambledWord
set UnScrambledNombre to EMPTY
repeat with i = 1 to wordLength
set i to i + 2
put char i of scrambledWord before UnScrambledNombre
end repeat
return UnScrambledNombre
end
on prepfrontpage
global stamp
if count(stamp) = 0 then
helpFrontPage()
go("frontpage")
else
writeLetter()
go("frontpage")
showDays()
end if
cursor(0)
end
on writeLetter
global usrName, endDate, beginDate, cycleNo, userNo, theDate
put getAt(usrName, userNo) & "," into field "greeting"
put EMPTY into field "helpgreeting"
put "Day " & differenceDate(beginDate, endDate) + 1 & ", " & GetLongDate(endDate) into field "firstDate"
put "Day " & differenceDate(beginDate, theDate) + 1 & ", " & GetLongDate(theDate) into field "lastDate"
set newFactNo to random(50)
put the text of field ("fact" && newFactNo) into field "today fact"
end
on helpFrontPage
global usrName, endDate, beginDate, userNo
put " " into field "firstDate"
put " " into field "lastDate"
put " " into field "today fact"
put getAt(usrName, userNo) & "," into field "greeting"
puppetSprite(9, 1)
set the visible of sprite 9 to 0
puppetSprite(9, 0)
put "Scientific evidence and statistical evaluation indicate that the information contained in this program is accurate. However, we cannot guarantee a 100% effectiveness rate. For best results in the application of this method, we recommend the guidance of a certified teacher of the Family of the Americas. You may call us at 1-800-443-3395 or (301)627-4351 or write FAF@IDSonline.com." into field "helpgreeting"
end
on showMonthlyDays
global stamp, mucus, relations, firstMonthlyDay
puppetStatus(11, 48, 1)
puppetVisible(11, 48, 1)
set max to count(stamp)
if max > 50 then
set max to 50
end if
set min to max - 12 + 1
if min < 1 then
set min to 1
end if
set firstMonthlyDay to min
if max <= 12 then
set the castNum of sprite 11 to cast "no scroll"
set the locH of sprite 11 to 191
set the locV of sprite 11 to 150
else
set the castNum of sprite 11 to cast "nob"
positionNob()
set max to min + 11
if max > 50 then
set max to 50
end if
end if
if min > 39 then
set the castNum of sprite 12 to cast "cal 0"
else
set the castNum of sprite 12 to cast ("cal" && min)
end if
set x to 1
repeat with i = min to max
set the castNum of sprite (12 + x) to cast ("ministamp " & string(getAt(stamp, i)))
if getAt(mucus, i) <> 0 then
set the castNum of sprite (24 + x) to cast ("miniMucus " & string(getAt(mucus, i)))
else
set the visible of sprite (24 + x) to 0
end if
if i < max then
set the castNum of sprite (36 + x) to cast ("miniRel " & string(getAt(relations, i)))
else
set the visible of sprite (36 + x) to 0
end if
set x to x + 1
updateStage()
end repeat
repeat with i = max + 1 to 12
set the visible of sprite (12 + i) to 0
set the visible of sprite (24 + i) to 0
set the visible of sprite (36 + i) to 0
end repeat
cursor(0)
end
on resetMonthlyDays
global stamp, mucus, relations, firstMonthlyDay
cursor(4)
go("monthly")
set min to firstMonthlyDay
set max to count(stamp)
if max > 50 then
set max to 50
end if
if max <= 12 then
set the castNum of sprite 11 to cast "no scroll"
set the locH of sprite 11 to 191
set the locV of sprite 11 to 150
else
set the castNum of sprite 11 to cast "nob"
positionNob()
set max to min + 11
if max > 50 then
set max to 50
set min to 39
end if
end if
if min > 39 then
set the castNum of sprite 12 to cast "cal 0"
else
set the castNum of sprite 12 to cast ("cal" && min)
end if
set x to 1
repeat with i = min to max
set the castNum of sprite (12 + x) to cast ("ministamp " & string(getAt(stamp, i)))
if getAt(mucus, i) <> 0 then
set the castNum of sprite (24 + x) to cast ("miniMucus " & string(getAt(mucus, i)))
set the visible of sprite (24 + x) to 1
else
set the visible of sprite (24 + x) to 0
end if
if i < count(stamp) then
set the castNum of sprite (36 + x) to cast ("miniRel " & string(getAt(relations, i)))
set the visible of sprite (36 + x) to 1
else
set the visible of sprite (36 + x) to 0
end if
set x to x + 1
updateStage()
end repeat
cursor(0)
end
on showDays
global stamp, mucus
puppetStatus(23, 48, 1)
set max to count(stamp)
if max > 50 then
set max to 50
end if
set min to max - 12 + 1
if min < 1 then
set min to 1
end if
if min > 39 then
set the castNum of sprite 24 to cast "cal 0"
else
set the castNum of sprite 24 to cast ("cal" && min)
end if
set x to 1
repeat with i = min to max
if getAt(stamp, i) <> 0 then
set the castNum of sprite (24 + x) to cast ("ministamp " & string(getAt(stamp, i)))
set the visible of sprite (24 + x) to 1
else
set the visible of sprite (24 + x) to 0
end if
if getAt(mucus, i) <> 0 then
set the castNum of sprite (25 + x) to cast ("miniMucus " & string(getAt(mucus, i)))
set the visible of sprite (25 + x) to 1
else
set the visible of sprite (25 + x) to 0
end if
set x to x + 2
updateStage()
end repeat
end
on hideDays
puppetVisible(23, 28, 1)
puppetStatus(23, 48, 0)
end
on fillWgooseEggs
global relations, stamp, mucus, advice, basis, comments
append(relations, 0)
append(stamp, 0)
append(mucus, 0)
append(advice, 0)
append(basis, 0)
append(comments, " ")
end
on NoDataThisDate
global endDate, theDate
fillWgooseEggs()
if endDate < getSerialDate(theDate) then
cursor(0)
go("date ok")
else
setupDayBook()
end if
end
on chartAnEntry
global stamp, endDate, PeakDayNo, theDate, cycleNo, userNo, currentCycleNo
set currentCycleNo to getAt(cycleNo, userNo)
if count(stamp) = 0 then
leaveFrontPage()
go("firstDay")
cursor(0)
else
if endDate >= getSerialDate(theDate) then
cursor(0)
alert("You have already charted for today. If you would like to change your entry, please use the daily calendar button.")
else
leaveFrontPage()
go("date ok")
cursor(0)
end if
end if
end
on leaveFrontPage
puppetSprite(9, 1)
set the visible of sprite 9 to 1
puppetSprite(9, 0)
end
on puppetStatus first, last, state
repeat with i = first to last
puppetSprite(i, state)
end repeat
end
on puppetVisible first, last, state
repeat with i = first to last
set the visible of sprite i to state
end repeat
end
on ask4date whichMonth
global newMonth, firstdayNo, numDaysInMonth, newday, newYear, theDate
cursor(4)
if (whichMonth = "previous") and (newMonth = value(item 1 of theDate)) then
set the visible of sprite 46 to 0
set the visible of sprite 47 to 1
set oldBox to newday + firstdayNo - 1
if (oldBox > 0) and (oldBox < 38) then
set the ink of sprite (oldBox + 8) to 36
end if
if newMonth > 1 then
set newMonth to newMonth - 1
set newYear to item 3 of theDate
else
set newMonth to 12
set newYear to getFullYear(item 3 of theDate) - 1
set newday to item 2 of theDate
end if
else
puppetStatus(1, 48, 0)
go("ask4date")
puppetVisible(1, 48, 1)
puppetStatus(9, 47, 1)
setDelimiter("/")
set the visible of sprite 47 to 0
set the visible of sprite 46 to 1
set newMonth to value(item 1 of theDate)
set newYear to item 3 of theDate
set newday to item 2 of theDate
end if
set serialdate to getSerialDate(string(newMonth & "/" & 1 & "/" & newYear))
set the text of member "month" to string(getMonth(serialdate))
if IsLeapYear(newYear) then
set numDays to [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
else
set numDays to [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
end if
set numDaysInMonth to getAt(numDays, newMonth)
setDelimiter()
set firstdayNo to serialdate mod 7
if firstdayNo = 0 then
set firstdayNo to 7
end if
set newBox to newday + firstdayNo - 1
if (newBox > 0) and (newBox < 38) then
set the ink of sprite (newBox + 8) to 2
end if
repeat with i = 29 to numDaysInMonth + firstdayNo
set the foreColor of sprite (i + 8) to 0
end repeat
repeat with i = numDaysInMonth + firstdayNo to 37
set the foreColor of sprite (i + 8) to 13
end repeat
set the castNum of sprite 7 to cast ("monthPos" && firstdayNo)
updateStage()
cursor(0)
end
on makeCal numDaysInMonth, firstdayNo
repeat with i = 1 to 37
put " " into field string(i)
end repeat
repeat with i = 1 to numDaysInMonth
put i into field string(i + firstdayNo - 1)
end repeat
end
on setUpBiodata
global bioInfo
set x to count(bioInfo)
repeat with i = 1 to x
set the hilite of member ("biodata " & getAt(bioInfo, i)) to 1
end repeat
go("biodata")
cursor(0)
end
on giveadvice
resetAdvice()
writecycleinfo()
end
on setupDayBook
giveadvice()
opendaybook()
end
on opendaybook
global endDate, mucus, stamp, advice, comments, dayNo
put EMPTY into field "advice"
put EMPTY into field "comments"
put EMPTY into field "basis"
go("setup daily cal")
puppetSprite(6, 1)
set the visible of sprite 6 to 0
puppetSprite(6, 0)
repeat with i = 17 to 21
puppetSprite(i, 1)
set the visible of sprite i to 0
puppetSprite(i, 0)
end repeat
go("daily cal")
set dayNo to count(stamp)
repeat with i = 3 to 5
puppetSprite(i, 1)
end repeat
put dayNo into field "dayNo"
put getDayOfWeek(endDate) && getDate(endDate) into field "date"
set the castNum of sprite 3 to cast "stamp 0"
set the castNum of sprite 4 to cast ("mucus" && getAt(mucus, dayNo))
set the castNum of sprite 5 to cast ("stamp" && getAt(stamp, dayNo))
set the text of member "advice" to the text of member ("advice" && getAt(advice, dayNo))
set the text of member "basis" to the text of member ("basis" && getAt(basis, dayNo))
put getAt(comments, dayNo) into field "comments"
cursor(0)
end
on leaveDayBook
global comments, dayNo
repeat with i = 17 to 21
puppetSprite(i, 0)
set the visible of sprite i to 1
puppetSprite(i, 0)
end repeat
puppetSprite(6, 1)
set the visible of sprite 6 to 1
puppetSprite(6, 0)
repeat with i = 3 to 5
puppetSprite(i, 0)
end repeat
if getAt(comments, dayNo) <> field "comments" then
setAt(comments, dayNo, field "comments")
end if
end
on previousPage
global dayNo
if dayNo < 2 then
cursor(0)
alert("Can't go past the beginning of the cycle.")
else
resetPage(-1)
end if
end
on nextPage
global stamp, dayNo, beginDate, theDate, cycleNo, userNo, currentCycleNo
if dayNo < count(stamp) then
resetPage(0)
else
if (beginDate + dayNo) > getSerialDate(theDate) then
cursor(0)
alert("Future calendar pages cannot be created.")
else
if getAt(cycleNo, userNo) <> currentCycleNo then
cursor(0)
alert("Cannot chart this cycle. Only current cycles may be charted.")
else
KeepChartIn()
end if
end if
end if
end
on resetPage direction
global endDate, beginDate, relations, mucus, stamp, advice, comments, dayNo
if getAt(comments, dayNo) <> field "comments" then
setAt(comments, dayNo, field "comments")
end if
if direction = 0 then
set dayNo to dayNo + 1
else
if direction = -1 then
set dayNo to dayNo - 1
else
set dayNo to direction
end if
end if
put dayNo into field "dayNo"
put getDayOfWeek(beginDate + dayNo - 1) && getDate(beginDate + dayNo - 1) into field "date"
if (beginDate + dayNo) > endDate then
set the castNum of sprite 3 to cast "stamp 0"
else
set the castNum of sprite 3 to cast ("relations" && getAt(relations, dayNo))
end if
set the castNum of sprite 4 to cast ("mucus" && getAt(mucus, dayNo))
set the castNum of sprite 5 to cast ("stamp" && getAt(stamp, dayNo))
set the text of member "advice" to the text of member ("advice" && getAt(advice, dayNo))
set the text of member "basis" to the text of member ("basis" && getAt(basis, dayNo))
put getAt(comments, dayNo) into field "comments"
updateStage()
cursor(0)
end
on KeepChartIn
global endDate, askedToKeepChartin, theDate
if askedToKeepChartin = 1 then
leaveDayBook()
go("date ok")
cursor(0)
else
set askedToKeepChartin to 1
set x to getSerialDate(theDate) - endDate
if x = 1 then
set ending to "day."
else
set ending to x & " days."
end if
put "No data has been charted for the next " & ending & " Would you like to chart these days now." into field "date ok"